Repository navigation
feat(schedule): book each card's hours: runs, priority changes and downtime - #328
Merged
Merged
Conversation
…wntime berthd keeps a schedule per card, up to 14 days ahead, in schedule.json. A run booking is an engine's turn: its waiter goes first, runs at the booking's priority, wins a tie against an unbooked holder, and keeps the card against everything but a hold until the booking ends. A priority booking moves an engine to another class for set hours. Downtime takes no new work and drains holders at the start; holds and trainings stay. Hours nobody booked run by priority, then arrival, as before. berth schedule shows what holds each card, the queue and the bookings, and books, moves and cancels them. The gateway's /v1/berth/schedule lets agents read the scheduler and book their own runs. The harbor gains a SCHEDULE tab with a 7-day board of 24-hour tracks, and a paired device books from it through berthd's socket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each card gets a schedule, up to 14 days ahead. The queue still decides who goes next; a booking decides whose hours they are.
What a booking does
runmin_turnstill protects the holder it takes over from.prioritydownHours nobody booked run by priority, then arrival, as before. A booked engine that does not ask for the card leaves it to everyone else. Two runs or downtimes on one card may not overlap, and neither may two priority changes for the same engine.
berth queue priowins over a booking, and a booking never moves a hold or a training.Where it shows up
berth schedulelists RUNNING, QUEUED and BOOKED.book,move IDandcancel IDchange the schedule.--days Nrepeats a booking on consecutive days, all or none, and--earliestfinds the first free hours.GET/POST /v1/berth/scheduleandPATCH/DELETE /v1/berth/schedule/{id}on the gateway. Agents book, move and cancel runs only. Priority changes and downtime stay the operator's, soPATCHorDELETEon one is a 403.POST /v1/board/schedule, which goes to berthd's socket and never to the gateway. The form says what the booking will do before you save it.bookings, and each lease carriesbooking(the ID that sets its class). Events:schedule.bookedandlease.booking_priority.schedule.jsonin its state directory (berth daemon --schedule,""turns it off).Proof
TestRunBookingLiftsItsWaiterAndDrainsALowerHolder,TestRunBookingWinsATie,TestRunBookingKeepsItsHolderUntilItEnds,TestRunBookingGoesFirstInLine,TestPriorityBookingMovesTheClassAndBack,TestDowntimeDrainsAndTakesNoNewWork. WithinRunforced false, all of them and the CLI end-to-end test go red. With the tie rule reverted,TestRunBookingWinsATiegoes red.earliest, all-or-nothingdays, rebook and unbook,Checkrefusals,ParseAt.TestBookingsReadTheNodesClockreproduces a live bug (a browser's UTC times showed as "Sun 06:00" for a 23:00 booking at UTC-7). It fails without the fix.TestScheduleAgainstADaemon(CLI),TestScheduleRoutesandTestScheduleRoutesLeaveTheOperatorsBookings(gateway),TestBoardSchedule(harbor, paired and unpaired).berth run --as sft --priority batchran at foreground under its run booking and drained a foregroundchatholder ("sft (foreground) needs the card"). The NOW panel showed BOOKED b4.go test ./..., the Windows build and vet, golangci-lint 2.14.0.